<%--
  Created by IntelliJ IDEA.
  User: baiyuhong
  Date: 2018/10/12
  Time: 10:18
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page isELIgnored="false" %>
<%@include file="include/publicMeta.jsp"%>

<article class="cl pd-20">
	<!-- 表单提交，注意action路径 -->
	<!-- 表单提交，注意action路径 -->
	<!-- 表单提交，注意action路径 -->
    <form action="/product/updateProduct" method="post" enctype="multipart/form-data" class="form form-horizontal" id="form-admin-add"  target="_parent">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>商品名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
				<!-- 传参 -->
                <input type="text" class="input-text" value="${product.proName}" placeholder="" id="name" name="name">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>商品单价：</label>
            <div class="formControls col-xs-8 col-sm-9">
				<!-- 传参 -->
                <input type="text" class="input-text" autocomplete="off" value="${product.proPrice}" placeholder="" id="price" name="price">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>人气：</label>
            <div class="formControls col-xs-8 col-sm-9">
				<!-- 传参 -->
                <input type="text" class="input-text" autocomplete="off" value="${product.proHot}" placeholder="" id="zan" name="zan">
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>销量：</label>
            <div class="formControls col-xs-8 col-sm-9">
				<!-- 传参 -->
                <input type="text" class="input-text" autocomplete="off" value="${product.proSale}" placeholder="" id="number" name="number">
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>描述：</label>
            <div class="formControls col-xs-8 col-sm-9">
				<!-- 传参 -->
                <input type="text" class="input-text" autocomplete="off" value="${product.proDesc}" placeholder="" id="miaoshu" name="miaoshu">
            </div>
        </div>

        <div class="row cl">

            <label class="form-label col-xs-4 col-sm-3"><span class="c-red"></span>商品图片：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <img id="img" src="${pageContext.request.contextPath}/${product.proPic}" width="100px" height="50px">
            </div>

            <label class="form-label col-xs-4 col-sm-3"><span class="c-red"></span>上传图片：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="file" name="image" accept="image/*" />
            </div>

        </div>


        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">分类：</label>
            <div class="formControls col-xs-8 col-sm-9"> <span class="select-box" style="width:150px;">
				<select class="select" name="cid" size="1">
					<!-- 传参 -->
                    <!-- 传参 -->
                    <!-- 传参 -->
                    <c:forEach items="${categoryList}" var="category">
                        <c:set var="crrent" value="false" />
                        <c:if test="${crrentCategory.id==category.id}">
                            <c:set var="crrent" value="true" />
                        </c:if>
                        <option value="${category.id}" ${crrent?"selected='selected'":"" } >${category.name}</option>
                    </c:forEach>
				</select>
				</span>
            </div>
        </div>

       <%--<div class="row cl">
           <form id="file-upload" role="form" >
           <div class="form-group">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red"></span>商品图片：</label>
            <div class="formControls col-xs-8 col-sm-9">
               <img id="img" src="${pageContext.request.contextPath}/resources/images/index/user.jpg" width="100px" height="50px">
            </div>

            <label class="form-label col-xs-4 col-sm-3"><span class="c-red"></span>上传图片：</label>
            <div class="formControls col-xs-8 col-sm-9">
              <input type="file"  name="file" accept="image/*">
            </div>

            <div>
              &lt;%&ndash;<input type="button" id="upload"  value="上传" />&ndash;%&gt;
            </div>
           </div>

           </form>
       </div>
--%>

        <%--<div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">商家：</label>
            <div class="formControls col-xs-8 col-sm-9"> <span class="select-box" style="width:150px;">
				<select class="select" name="bid" size="1">
					<!-- 传参 -->
					<!-- 传参 -->
					<!-- 传参 -->
                    <c:forEach items="${userList}" var="user">
                        <c:set var="crrent1" value="false" />
                        <c:if test="${crrentUser.id==user.id}">
                            <c:set var="crrent1" value="true" />
                        </c:if>
                        <option value="${user.uid}" ${crrent1?"selected='selected'":"" } >${user.username}</option>
                    </c:forEach>
				</select>
				</span>
            </div>
        </div>--%>
            <input type="hidden" name="id" value="${product.pid}" />
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input id="upload" class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</article>
<%@include file="include/publicFooter.jsp"%>

<script type="text/javascript">
    $(function(){
        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });


    });

   /* $("#upload").click(function () {
        //数据来源哪里? 表单
        var date=new FormData($("#form-admin-add")[0]);
        alert(date);
        $.ajax({
            url:"/product/upload",
            data:date,//传给服务端的数据
            type:"post",//请求类型
            contentType:false,//提交给服务端的数据类型 要不要当成字符串来处理
            processData:false,//要不要处理提交的数据
            dataType:"json",//服务端返回的数据类型
            success:function (data) {//回调函数
                if (data.state==200){
                    layer.msg(data.msg);
                    //将图片路径显示<img> 的src属性
                    $("#img").attr("src","${pageContext.request.contextPath}/"+"images/"+"product/"+data.path);
                    //将修改后的文件名保存在cookie中
                    $.cookie("image",data.path,{expires:7});
                }else {
                    layer.msg(data.msg);
                }
            }
        })
    });
    //页面加载完成后
    $(function () {
        var proPic = $.cookie("image");
        ///给img赋值
        $("#img").attr("src","${pageContext.request.contextPath}/images/product/"+proPic);

    });*/
</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>